home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Annotations / Remove Tags < prev   
Text File  |  1996-02-28  |  1KB  |  64 lines

  1. #include <AnnotationInfo Procs>
  2. #include <Keyword-Value>
  3. | Remove Tags
  4.  
  5. #pragma rtGlobals=1
  6.  
  7. Menu "Graph"
  8.     "-"
  9.     "Remove Tags..."
  10. End
  11.  
  12. Proc RemoveTags(which)
  13.     Variable which=1
  14.     Prompt which,"Remove which tags?",popup,"all tags;all tags attached off-screen"
  15.     
  16.     Silent 1;PauseUpdate
  17.     String ann,axis,wv,info,str=AnnotationList("")
  18.     Variable offset1, offset2,len,del,instance,hash
  19.     offset1 = 0
  20.     do
  21.         offset2 = StrSearch(str, ";" , offset1)
  22.         if (offset2 == -1)
  23.             break;
  24.         endif
  25.         ann= str[offset1, offset2-1]
  26.         info=AnnotationInfo("",ann)
  27.         if( CmpStr(AnnotationType(info),"Tag")==0 )
  28.             del=1
  29.             if(which == 2)    | delete only off-screen tags
  30.                 del=TagIsOffScreen(info)
  31.             endif
  32.             if( del )
  33.                 Tag/K/N=$ann
  34.             endif
  35.         endif
  36.         offset1 = offset2+1
  37.     while (1)
  38. End
  39.  
  40.  
  41. Function TagIsOffScreen(info)
  42.     String info
  43.  
  44.     String axis,wv,tinfo
  45.     Variable instance,hash,offscreen
  46.     Variable/D xAttach= AnnotationAttachX(info)
  47.     wv= AnnotationYWave(info)        | wave tag is attached to
  48.     hash=strsearch(wv,"#",0)
  49.     if(hash != -1 )
  50.         instance=str2num(wv[hash+1,99])
  51.         wv[hash,99]=""
  52.     endif
  53.     tinfo=TraceInfo("",wv,instance)
  54.     axis=StrByKey("XAXIS",tinfo)    | X axis wave is graphed against
  55.     GetAxis/Q $axis
  56.     if( V_Min > V_Max )        | V_Min and V_Max are actually left and right values
  57.         Variable/D tmp=V_Max
  58.         V_Max= V_Min
  59.         V_Min= tmp
  60.     endif
  61.     offscreen= xAttach != limit(xAttach,V_Min,V_Max)
  62.     return offscreen
  63. End
  64.